package bishi.tengxun.three;

import java.util.Scanner;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2021/09/26 19:57
 */
public class one {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n > 0) {
            n--;
            int now = sc.nextInt();
            int[] nums = new int[2];
            int index = 1+now;
            for (int i=0;i<2;i++){
                for (;;index++){
                    int j=2;
                    for (j=2;j<index;j++){
                        if (index%j==0){
                            break;
                        }
                    }
                    if (index==j){
                        nums[i] = index;
                        break;
                    }
                }
                index+=now;
            }
            System.out.println(nums[0]*nums[1]);
        }
    }
}
